package dao;

import entity.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import util.DBUtil;

import java.sql.SQLException;

/**
 * @author 孙亚梅
 * @version V1.0
 * @Project javase2203
 * @Package dao
 * @Description:
 * @Date 2022/5/27 12:35
 */
public class UserdaoImpl implements  UserDao{

    private QueryRunner runner = new QueryRunner(DBUtil.getDateSource());

    @Override
    public User selectUser(String uname) {
       String sql = "select *from user where username=?;";
        try {
            User user = runner.query(sql,new BeanHandler<User>(User.class),uname);
            return user;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  null;
    }
}
